function [QT,QT_err] = Herror_charge(alpha_sweep,H_berry_curvature, H_berry_err)
    % calculates the topological charge
    % takes alpha_sweep which is not equidistant
    
    QT=sum((H_berry_curvature(1:end-1)+H_berry_curvature(2:end)).*(alpha_sweep(2:end)-alpha_sweep(1:end-1)));
    
    QT_err=sqrt(sum((H_berry_err(1:end-1).^2+H_berry_err(2:end).^2).*(alpha_sweep(2:end)-alpha_sweep(1:end-1)).^2));
    
    
